﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace MasterServer.Common.Helpers
{
    public static class SecurityHelper
    {
        public static string GetMD5String(string input)
        {
            MD5 md5 = new MD5CryptoServiceProvider();
            md5.Initialize();
            byte[] inputBuffer = Encoding.UTF8.GetBytes(input);
            byte[] buffer = md5.ComputeHash(inputBuffer);
            StringBuilder sb = new StringBuilder();
            foreach (byte b in buffer)
            {
                sb.Append(b.ToString("X2"));
            }
            return sb.ToString();
        }
        public static string GetSecureDBHash(string input)
        {
            string str = GetMD5String(input);
            str = GetMD5String("SecReT!Key&*" + str + "MeGaHashFUn^*ction!");
            return str;
        }
    }
}
